from django.contrib import admin
from .models import KeywordTask, ProductListTask, RankingScreenShot
from Task.models import Task
from django.contrib import admin
import urllib


class KeywordTaskAdmin(admin.ModelAdmin):
    list_display = ('keyword', )
    readonly_fields = ['keyword', 'tasks']

class ProductListTaskAdmin(admin.ModelAdmin):
    list_display = ('name', )
    readonly_fields = ['task']


class RankingScreenShotAdmin(admin.ModelAdmin):
    list_display = ('date', 'name', 'page', 'preview')
    search_fields = ('name',)
    list_filter = ('date',)
    def preview(self, obj):
        return urllib.unquote(obj.content.url)

admin.site.register(KeywordTask, KeywordTaskAdmin)
admin.site.register(ProductListTask, ProductListTaskAdmin)

admin.site.register(RankingScreenShot, RankingScreenShotAdmin)
